package edu.ccut.saturn.basevalidate.prvalidate;

import java.util.Map;

import edu.ccut.saturn.component.DefaultSaturnValidate;
import edu.ccut.saturn.component.ValidateResult;

public class HasChineseValidate extends DefaultSaturnValidate {

	private static final String chineseRegExpr = "[^\\x00-\\xff]";

	public void doValidate(Object value, Object[] args, ValidateResult result) {
		if (value != null) {
			Map<String, String> errorInfos = getErrorInfos();
			if (!(value.toString()).matches(chineseRegExpr)) {
				
				String errorKey = "_error_";
				String errorInfo = null;
				if (errorInfos != null) {
					errorInfo = errorInfos.get(errorKey);
				}
				result.addValidateError(errorInfo, value);
			}
		}
	}

}
